﻿using SqlSugar;
using SmartAnswerPlatform.Models.Entitys.Base;
using System.Linq.Expressions;
using SmartAnswerPlatform.Models.ViewModels;


namespace SmartAnswerPlatform.IRepository
{
    public interface IBaseRepository<TEntity> where TEntity : BaseEntity, new()
    {
        /// <summary>
        /// 根据id查询
        /// </summary>
        /// <param name="id"></param>
        /// <returns>查询到的实体</returns>
        Task<TEntity> FindById(string id);
        /// <summary>
        /// 根据多个id查询
        /// </summary>
        /// <param name="ids">id集合</param>
        /// <returns>查询到的多个实体集合</returns>
        Task<List<TEntity>> FindByIds(List<string> ids);
        /// <summary>
        /// 查询全部内容
        /// </summary>
        /// <returns>返回所有内容</returns>
        Task<List<TEntity>> FindAll();
        /// <summary>
        /// 根据表达式查询
        /// </summary>
        /// <param name="expression">表达式目录树</param>
        /// <returns>查询到的结果集</returns>
        Task<List<TEntity>> FindByWhere(Expression<Func<TEntity, bool>> expression);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity">修改实体</param>
        /// <returns>受影响行数</returns>
        Task<int> Update(TEntity entity);
        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="entities">需要修改的实体集合</param>
        /// <returns>受影响行数</returns>
        Task<int> UpdateRange(List<TEntity> entities);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id">id主键</param>
        /// <returns>删除的受影响行数</returns>
        Task<int> Delete(string id);
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="ids">id集合</param>
        /// <returns>受影响行数</returns>
        Task<int> DeleteRange(List<string> ids);
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity">添加的实体</param>
        /// <returns>添加后的实体</returns>
        Task<TEntity> Insert(TEntity entity);
        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="entities">需要添加的实体集合</param>
        /// <returns>添加后的受影响行数</returns>
        Task<int> InsertRange(List<TEntity> entities);

        /// <summary>
        /// 新增处理基础属性
        /// </summary>
        /// <returns></returns>
        void AddSetBasicProperties(TEntity entity);

        /// <summary>
        /// 修改处理基础属性
        /// </summary>
        /// <returns></returns>
        void updateSetBasicProperties(TEntity entity);

    }
}